package com.bjbn.controller;

import com.bjbn.model.dto.BaseResponseDto;
import com.bjbn.model.dto.GpsDataRequestDto;
import com.bjbn.model.dto.GpsDataResponseDto;
import com.bjbn.model.dto.HotAreaRequestDto;
import com.bjbn.model.dto.HotAreaResponseDto;
import com.bjbn.model.dto.TaxiBaseInfoRequestDto;
import com.bjbn.model.dto.TaxiBaseInfoResponseDto;
import com.bjbn.service.TransitAuthorityService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 广州市交通局网约车数据接口控制器
 */
@RestController
@RequestMapping("/api/transit-authority")
@RequiredArgsConstructor
@Slf4j
@Tag(name = "广州市交通局网约车数据接口", description = "提供广州市交通局网约车相关数据的统一接口访问服务")
public class TransitAuthorityController {

    private final TransitAuthorityService transitAuthorityService;

    /**
     * 获取网约车GPS数据
     */
    @PostMapping("/gps-data")
    @Operation(summary = "获取网约车GPS数据", description = "根据日期、时间和车牌号等条件获取网约车的GPS数据")
    @ApiResponses(value = {
            @ApiResponse(responseCode = "200", description = "成功", content = @Content(schema = @Schema(implementation = BaseResponseDto.class))),
            @ApiResponse(responseCode = "500", description = "服务器错误")
    })
    public BaseResponseDto<GpsDataResponseDto> getGpsData(
            @RequestBody @Parameter(description = "GPS数据查询条件", required = true) GpsDataRequestDto requestDto,
            @RequestParam(defaultValue = "1") @Parameter(description = "当前页码", example = "1") String page,
            @RequestParam(defaultValue = "10") @Parameter(description = "每页记录数", example = "10") String pageSize) {
        log.info("接收网约车GPS数据请求");
        return transitAuthorityService.getGpsData(requestDto, page, pageSize);
    }

    /**
     * 获取网约车下车客流热力图数据
     */
    @PostMapping("/drop-off-hot-area")
    @Operation(summary = "获取网约车下车客流热力图数据", description = "根据日期和小时获取网约车的下车客流热力图数据")
    @ApiResponses(value = {
            @ApiResponse(responseCode = "200", description = "成功", content = @Content(schema = @Schema(implementation = BaseResponseDto.class))),
            @ApiResponse(responseCode = "500", description = "服务器错误")
    })
    public BaseResponseDto<HotAreaResponseDto> getDropOffHotArea(
            @RequestBody @Parameter(description = "下车客流热力图查询条件", required = true) HotAreaRequestDto requestDto,
            @RequestParam(defaultValue = "1") @Parameter(description = "当前页码", example = "1") String page,
            @RequestParam(defaultValue = "10") @Parameter(description = "每页记录数", example = "10") String pageSize) {
        log.info("接收网约车下车客流热力图数据请求");
        return transitAuthorityService.getDropOffHotArea(requestDto, page, pageSize);
    }

    /**
     * 获取网约车上车客流热力图数据
     */
    @PostMapping("/pick-up-hot-area")
    @Operation(summary = "获取网约车上车客流热力图数据", description = "根据日期和小时获取网约车的上车客流热力图数据")
    @ApiResponses(value = {
            @ApiResponse(responseCode = "200", description = "成功", content = @Content(schema = @Schema(implementation = BaseResponseDto.class))),
            @ApiResponse(responseCode = "500", description = "服务器错误")
    })
    public BaseResponseDto<HotAreaResponseDto> getPickUpHotArea(
            @RequestBody @Parameter(description = "上车客流热力图查询条件", required = true) HotAreaRequestDto requestDto,
            @RequestParam(defaultValue = "1") @Parameter(description = "当前页码", example = "1") String page,
            @RequestParam(defaultValue = "10") @Parameter(description = "每页记录数", example = "10") String pageSize) {
        log.info("接收网约车上车客流热力图数据请求");
        return transitAuthorityService.getPickUpHotArea(requestDto, page, pageSize);
    }

    /**
     * 获取网约车辆基础信息
     */
    @PostMapping("/taxi-base-info")
    @Operation(summary = "获取网约车辆基础信息", description = "根据车辆类型、证件状态、车牌号等条件获取网约车辆的基础信息")
    @ApiResponses(value = {
            @ApiResponse(responseCode = "200", description = "成功", content = @Content(schema = @Schema(implementation = BaseResponseDto.class))),
            @ApiResponse(responseCode = "500", description = "服务器错误")
    })
    public BaseResponseDto<TaxiBaseInfoResponseDto> getTaxiBaseInfo(
            @RequestBody @Parameter(description = "车辆基础信息查询条件", required = true) TaxiBaseInfoRequestDto requestDto,
            @RequestParam(defaultValue = "1") @Parameter(description = "当前页码", example = "1") String page,
            @RequestParam(defaultValue = "10") @Parameter(description = "每页记录数", example = "10") String pageSize) {
        log.info("接收网约车辆基础信息请求");
        return transitAuthorityService.getTaxiBaseInfo(requestDto, page, pageSize);
    }
}